package com.hjk.waibao.mj;


import com.hjk.waibao.mj.common.model._MappingKit;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;

import java.util.regex.Pattern;

/**
 * @Description
 * @Author hjk
 * @Date 2020/4/22
 **/
public class Test {

    static Pattern ATTR_LINE_PATTERN = Pattern.compile("(\\S+?)[:：]([\\s\\S]+?[,，]?)*");

    public static Prop p = PropKit.use("config-dev.properties");

    public static void main1(String[] args) throws InterruptedException {
//        for (int i = 1; i <= 50; i++) {
//            System.out.println("\"col" + i + "\": true,");
//        }

//        loadDB();
//        Screenshot screenshot = new Screenshot();
//        screenshot.setId(6);
//        screenshot.setUrl("https://www.amazon.com/dp/B089KRZV1G");
//        screenshot.setFileName("39.pdf");
//        screenshot.setStatus("1");
//        screenshot.setCreateTime(new Date());
//        ScreenshotExecutor.run(screenshot);
//        while (true) {
//            Thread.sleep(1000);
//        }
    }

    public static void loadDB() {
        //配置url
        DruidPlugin druidPlugin = createDruidPlugin();
//        Db.use(druidPlugin.getDataSource());
        ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
        _MappingKit.mapping(arp);
        druidPlugin.start();
        arp.start();
    }

    public static DruidPlugin createDruidPlugin() {
        return new DruidPlugin(p.get("jdbcUrl"), p.get("user"), p.get("password").trim());
    }

}